﻿using Kingdee.SDK.Client;
using Kingdee.SDK.com.kingdee.service.data.api;
using Kingdee.SDK.com.kingdee.service.data.entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Kingdee.SDK.TGTEST
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello, World!");

            invosdk();

        }

        static void invosdk()
        {

            string ClientID = "268149";
            string ClientSecret = "d57710a947f43ae6c2f0d4d57b1a5a0c";
            string outerInstanceId = "227496776318455808";


            Configuration cfg = new Configuration()
            {
                ClientId = ClientID,
                ClientSecret = ClientSecret
            };


            //初始化AppToken信息

            AuthorizeApi authorizeApi = new AuthorizeApi(cfg);
            var authorList = authorizeApi.AsterAuthorize(outerInstanceId);//此参数替换成自己的

            //这里取自己对应产品的appKey
            var appKey = authorList.First().AppKey;
            var appSecret = authorList.First().AppSecret;

            AppTokenApi appTokenApi = new AppTokenApi(cfg);

            string appSignature = SHAHelper.HmacSHA256(appSecret, appKey);
            AsterAppTokenRes asterAppTokenRes = appTokenApi.AsterAppToken(appKey, appSignature, null);
            // 保存AppToken ，有效期为24小时，过期后重新获取
            cfg.AppToken = asterAppTokenRes.AppToken;


            //## 步骤四：使用.NET SDK 调用业务接口
            //例如，调用一个科目列表API方法：
            //使用配置文件创建一个业务对象

            SalOutBoundApi instance = new SalOutBoundApi(cfg);

            ///传参有bug，草！！！！！！！！
/*            SalOutBoundListReq body = new SalOutBoundListReq()
            {
                Page = "1",
                PageSize = "1",
                *//*                        StartBillDate = "2024-01-01",
                                        EndBillDate = "2024-01-31"*//*
            };*/
            SalOutBoundListReq body = null;
            var response = instance.SalOutBoundList(body);
        }
    }
}